from redis import Redis

if __name__ == '__main__':
    redis = Redis(host='127.0.0.1', port=6379, password='', db=0)
    redis.set("name", "alex")
    print(redis.get("name").decode())
    data = {
        "name": "xiaohong",
        "age": 12,
        "sex": 1
    }
    redis.hset("user", mapping=data)
    print({key.decode(): value.decode() for key, value in redis.hgetall("user").items()})
    print(redis.keys("*"))
    print(len(redis.keys("*")))